Repository navigation
Conversation
This was referenced Oct 15, 2026
Open
robobun
force-pushed
the
robobun/5627effc/node-http-rawpacket-method
branch
from
October 15, 2026 20:32
c2b76a4 to
de273e4
Compare
robobun
force-pushed
the
robobun/5627effc/serve-method-id-rust
branch
from
October 15, 2026 20:32
45d2e2c to
9e5913c
Compare
robobun
force-pushed
the
robobun/5627effc/node-http-rawpacket-method
branch
from
October 15, 2026 21:45
de273e4 to
8b4be0f
Compare
robobun
force-pushed
the
robobun/5627effc/serve-method-id-rust
branch
from
October 15, 2026 21:57
9e5913c to
ed1a9e9
Compare
robobun
force-pushed
the
robobun/5627effc/node-http-rawpacket-method
branch
3 times, most recently
from
October 17, 2026 10:06
84f2a1d to
c5d8886
Compare
robobun
force-pushed
the
robobun/5627effc/serve-method-id-rust
branch
from
October 17, 2026 10:06
ed1a9e9 to
41e84b1
Compare
Request::method() returns the Method for the id that the parser stored on the request. A handler runs only for a request that has one, so the 12 lookups that substituted GET, POST or OPTIONS for a name they did not know go, with the Option<Method> parameters that carried a second copy of the method.
robobun
force-pushed
the
robobun/5627effc/serve-method-id-rust
branch
from
October 17, 2026 11:03
41e84b1 to
6005a00
Compare
robobun
force-pushed
the
robobun/5627effc/node-http-rawpacket-method
branch
from
October 17, 2026 11:03
c5d8886 to
5c34108
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
METHOD_MAP. 12 readers handle a failed lookup. 10 of them substituteGET,POSTorOPTIONS(RequestContext.rs:1426,DevServer.rs:1774).Fix
Request::method()returns aMethod. The shim asks uWS for the id of the method (uws_req_get_method_id).Option<Method>parameters with them. So doMethod::find(),RouteMethod::specific()and the string fallback inNodeHTTP.cpp.Methodfails a debug assertion. A release build reads it asGET, as before.Behaviour change: none
Tests that cover this code:
test/js/bun/http/bun-serve-routes.test.ts(each of the 36 methods must arrive asreq.method),test/js/node/http/node-http.test.ts,test/js/bun/http/serve-http2.test.ts,test/js/bun/http/serve-http3.test.ts,test/js/bun/http/bun-serve-file.test.ts.Background
methodIdFromWire()(uws: resolve a request method to its id inline #44510) maps a method name to the discriminant ofMethod.Method::from_reprcosts one compare.Downsides
:methodreaches a handler: a debug build fails the assertion, andPatCharrives asGET, notPATCH.Method::which(22 for GET) goes. Release binary: 8,704 bytes smaller.Notes
RequestContext.rs:1426,StaticRoute.rs:292,FileRoute.rs:233,DirectoryRoute.rs:107andDevServer.rs:2129(GET).DevServer.rs:1774and:2099(POST).mod.rs:758,server_body.rs:2904andNodeHTTPResponse.rs:2751(OPTIONS, for the body length).mod.rs:1315passedundefinedto C++, which then made a string from the name (NodeHTTP.cpp:96).HTMLBundle.rs:276answered 405.methodparameter and read it from the request:prepare_js_request_context,prepare_js_request_context_for,prepare_and_save_js_request_contextandupgrade_web_socket_user_route.RequestContext::createandcreate_intake aMethod.RouteMethod::specific()gave the method of a route to its handler. It was always the method of the request: theHEADthat Bun derives from aGETroute is registered as aHEADroute.PatCharrives asPATCHandBREWasGET. With this PR and no HTTP/3 check both arrive asGETin a release build, and a debug build fails the assertion.DevServer.rsintodev_server/, and three of the removed arms are there.fetch. fetch, Request, server.fetch: stop sending GET for a method outside the method table #44718 (open) lets aRequestcarry any method token. This PR and uws: key HttpRouter by method id #45400 remove the method name from the path between uWS and Rust, so a request with no method id has no name to deliver. If maintainers want such a request delivered, the name must stay readable for it. That needs a maintainer decision.MethodasGET. That is what each of the 10 arms did. uws: key HttpRouter by method id #45400 makes the router refuse such an id, and thenRequest::method()asserts it in release builds too.HttpParser.handHttpRouter.h, clang -O3,qemu-x86_64 -one-insn-per-tb -d exec,nochain), node:http: keep the method of a dispatched request as sent in 'clientError' rawPacket #45398 then this PR: GET 2395, 2412. POST 2697, 2710. The 17 and 13 more aremethodIdFromWire()in the shim. In Rust,Method::whichgoes: 31 instructions per call forGETand 30 forPOSTin a loop whose empty body costs 9 and 5 (cargo build --releaseof an example that calls it, same counter). The slice that the old shim returned goes too and is not counted.perfis not available in the build container (perf_event_paranoidis 4), andvalgrindis not installed.llvm-size): text 80,701,779 -> 80,693,075 bytes (node:http: keep the method of a dispatched request as sent in 'clientError' rawPacket #45398, then this PR, on base f4d755a; measured before the two id getters moved into this PR). data and bss do not change.bun-serve-routes(86 tests),node-http-pipeline-callbacks,node-http,serve-http2,serve-http2-protocol,serve-http3,bun-serve-static,bun-serve-file,serve-directory-routes,bun-serve-html. On uws: key HttpRouter by method id #45400, which has this change: alsonode-http-displaced-response,request-smuggling, threetest-http-*-client-errorNode tests, andserve.test.ts.